package com.goldsprite.spinelearn.examples.gfsm.states;

import com.goldsprite.gdxcore.gfsm.State;
import com.goldsprite.spinelearn.examples.AnimType;
import com.goldsprite.spinelearn.examples.gfsm.SpineStateMachine;

public class SpineAttackState extends State<SpineStateMachine> {
	private float oldDirX;
	@Override
	public boolean canEnter() {
		return fsm.getInput().isAttacking();
	}

	@Override
	public boolean canExit() {
		boolean safeMove = fsm.getInput().isSafeMoving();
		return fsm.getEntity().isAnimationComplete() || safeMove;
	}

	@Override
	public void enter() {
		oldDirX = fsm.getInput().getMoveDirection();
		fsm.getInput().setMoveProtect(true);//设置移动保护, 需要抬起移动键解除
		fsm.getInput().setAttacking(false);
		fsm.getEntity().playAnim(AnimType.ATTACK, false);
		System.out.println("进入攻击状态");
	}
}
